import argparse
import re
import line_profiler
import sys

def cou_char(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        txt = file.read()
        return len(txt)

def cou_words(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        txt = file.read()
        num_words = re.findall(r'\b\w+\b', txt)
        return len(num_words)

def cou_sen(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        txt = file.read()
        num_sen = re.split(r'[.!?]', txt)
        num_sen = [i.strip() for i in num_sen if i.strip()]
        return len(num_sen)
def main():
    file_path = 'test.txt'
    profile_1 = line_profiler.LineProfiler(cou_char)
    profile_1.enable()
    cou_char(file_path)
    profile_1.disable()
    profile_1.print_stats(sys.stdout)

    profile_2 = line_profiler.LineProfiler(cou_words)
    profile_2.enable()
    cou_words(file_path)
    profile_2.disable()
    profile_2.print_stats(sys.stdout)

    profile_3 = line_profiler.LineProfiler(cou_sen)
    profile_3.enable()
    cou_sen(file_path)
    profile_3.disable()
    profile_3.print_stats(sys.stdout)

if __name__ == "__main__":
    main()